<?php

namespace app\modules\setting\configs\workspaces;

use sookie\excel\SaveExcel;
use yii\db\ActiveRecord;
use sookie\react\handlers\UrlHandler;
use yii\helpers\Json;
use app\modules\setting\models\workspaces\SetWorkspacesSjdl;
use sookie\bootstraps\handlers\AuthChecker;

/**
* Class TestConfig
* @package sookie\react\configs
* app\modules\setting\configs\workspaces\SjdlConfig 模型的配置类
*/
class SjdlConfig{

    /**
    * @return array
    * 获取搜索表单配置
    */
    public static function getSearchConfig(){
    return [
            [
                "component" => "FormInput",
                "field" => "responseid",
                "label" => "结果id",
                "placeholder" => "结果id",
                "allowClear" => true,
            ],

            [
                "component" => "FormInput",
                "field" => "nickname",
                "label" => "昵称",
                "placeholder" => "昵称",
                "allowClear" => true,
            ],

            [
                "component" => "FormInput",
                "field" => "email",
                "label" => "邮箱",
                "placeholder" => "邮箱",
                "allowClear" => true,
            ],

    ];
    }

    /**
    * @return array
    * 获取表格的操作
    */
    public static function getTableActions(){
        return  [
        ];
    }

    /**
    * @return array
    * 获取表格行的操作
    * [] 表示要id, ["*"] 表示要一行记录,参数名record, ["id"] 指定需要的参数 ， selected_ids 表示需要所有选择的id
    * configParamsField 规定请求的时候带上数据行中的那些参数，只需要字段名
    */
    public static function getTableRowAction(){
        return [
            [
                "actionType" => "MODAL",
                "config" => [
                    "footer" => false,
                    "title" => "查看",
                    "alert" => [
                        "description" => "以下展示了该模型所有的字段信息"
                    ]
                ],
                "configUri" => UrlHandler::toAction("workspaces/sjdl","view"),
                "auth" => AuthChecker::doPermissionCheck("workspaces/sjdl","view"),
                "configParamsField" => ["id"],
                "label" => "查看"
            ],
        ];
    }

    /**
    * @return array
    * 获取表格配置
    */
    public static function getTableConfig(){
        return [
            "rowKey" => "id",
            "columns" => [
                [
                    "title" => "结果id",
                    "dataIndex" => "responseid",
                    "sorter" => true,
                    "key" => "responseid",
                    "format" => "text",
                ],
                [
                    "title" => "邮箱",
                    "dataIndex" => "email",
                    "sorter" => true,
                    "key" => "email",
                    "format" => "text",
                ],
                [
                    "title" => "昵称",
                    "dataIndex" => "nickname",
                    "sorter" => true,
                    "key" => "nickname",
                    "format" => "text",
                ],
                [
                    "title" => "头像",
                    "dataIndex" => "avatar",
                    "sorter" => true,
                    "key" => "avatar",
                    "format" => "text",
                ],
                [
                    "title" => "粉丝数",
                    "dataIndex" => "followers",
                    "sorter" => true,
                    "key" => "followers",
                    "format" => "text",
                ],
                [
                    "title" => "点赞数",
                    "dataIndex" => "hearts",
                    "sorter" => true,
                    "key" => "hearts",
                    "format" => "text",
                ],
                [
                    "title" => "视频数",
                    "dataIndex" => "videos_count",
                    "sorter" => true,
                    "key" => "videos_count",
                    "format" => "text",
                ],
                [
                    "title" => "关注数",
                    "dataIndex" => "following",
                    "sorter" => true,
                    "key" => "following",
                    "format" => "text",
                ],
                [
                    "title" => "influencer_id",
                    "dataIndex" => "influencer_id",
                    "sorter" => true,
                    "key" => "influencer_id",
                    "format" => "text",
                ],
                [
                    "title" => "biography",
                    "dataIndex" => "biography",
                    "sorter" => true,
                    "key" => "biography",
                    "format" => "text",
                ],
            ],
            "actions" => self::getTableRowAction()
        ];
    }

    /**
    * 首页配置
    */
    public static function configIndex(){
        return [
            //搜索表单配置
            "searchConfig" => self::getSearchConfig(),
            // 操作配置 configParams 规定请求的时候带上那些参数
            "actionDivConfig" => self::getTableActions(),
            //表格配置
            "tableConfig" => self::getTableConfig(),
        ];
    }

    /**
    * @return array
    * 查看配置 format 可选 text pic video link
    */
    public static function configView(){
        return [
            "type" => "DETAIL",
            "config" => [
                [
                    "field" => "responseid",
                    "label" => "结果id",
                    "format" => "text",
                ],
                [
                    "field" => "res",
                    "label" => "结果集",
                    "format" => "text",
                ],
                [
                    "field" => "email",
                    "label" => "邮箱",
                    "format" => "text",
                ],
                [
                    "field" => "nickname",
                    "label" => "昵称",
                    "format" => "text",
                ],
                [
                    "field" => "avatar",
                    "label" => "头像",
                    "format" => "text",
                ],
                [
                    "field" => "followers",
                    "label" => "粉丝数",
                    "format" => "text",
                ],
                [
                    "field" => "hearts",
                    "label" => "点赞数",
                    "format" => "text",
                ],
                [
                    "field" => "videos_count",
                    "label" => "视频数",
                    "format" => "text",
                ],
                [
                    "field" => "following",
                    "label" => "关注数",
                    "format" => "text",
                ],
                [
                    "field" => "influencer_id",
                    "label" => "influencer_id",
                    "format" => "text",
                ],
                [
                    "field" => "biography",
                    "label" => "biography",
                    "format" => "text",
                ],
            ]
        ];
    }





}

